//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for ServiceQuotas
public struct ServiceQuotasErrorType: AWSErrorType {
    enum Code: String {
        case aWSServiceAccessNotEnabledException = "AWSServiceAccessNotEnabledException"
        case accessDeniedException = "AccessDeniedException"
        case dependencyAccessDeniedException = "DependencyAccessDeniedException"
        case illegalArgumentException = "IllegalArgumentException"
        case invalidPaginationTokenException = "InvalidPaginationTokenException"
        case invalidResourceStateException = "InvalidResourceStateException"
        case noAvailableOrganizationException = "NoAvailableOrganizationException"
        case noSuchResourceException = "NoSuchResourceException"
        case organizationNotInAllFeaturesModeException = "OrganizationNotInAllFeaturesModeException"
        case quotaExceededException = "QuotaExceededException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case serviceException = "ServiceException"
        case serviceQuotaTemplateNotInUseException = "ServiceQuotaTemplateNotInUseException"
        case tagPolicyViolationException = "TagPolicyViolationException"
        case templatesNotAvailableInRegionException = "TemplatesNotAvailableInRegionException"
        case tooManyRequestsException = "TooManyRequestsException"
        case tooManyTagsException = "TooManyTagsException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize ServiceQuotas
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The action you attempted is not allowed unless Service Access with Service Quotas is enabled in your organization.
    public static var aWSServiceAccessNotEnabledException: Self { .init(.aWSServiceAccessNotEnabledException) }
    /// You do not have sufficient permission to perform this action.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// You can't perform this action because a dependency does not have access.
    public static var dependencyAccessDeniedException: Self { .init(.dependencyAccessDeniedException) }
    /// Invalid input was provided.
    public static var illegalArgumentException: Self { .init(.illegalArgumentException) }
    /// Invalid input was provided.
    public static var invalidPaginationTokenException: Self { .init(.invalidPaginationTokenException) }
    /// The resource is in an invalid state.
    public static var invalidResourceStateException: Self { .init(.invalidResourceStateException) }
    /// The account making this call is not a member of an organization.
    public static var noAvailableOrganizationException: Self { .init(.noAvailableOrganizationException) }
    /// The specified resource does not exist.
    public static var noSuchResourceException: Self { .init(.noSuchResourceException) }
    /// The organization that your account belongs to is not in All Features mode.
    public static var organizationNotInAllFeaturesModeException: Self { .init(.organizationNotInAllFeaturesModeException) }
    /// You have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.
    public static var quotaExceededException: Self { .init(.quotaExceededException) }
    /// The specified resource already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// Something went wrong.
    public static var serviceException: Self { .init(.serviceException) }
    /// The quota request template is not associated with your organization.
    public static var serviceQuotaTemplateNotInUseException: Self { .init(.serviceQuotaTemplateNotInUseException) }
    /// The specified tag is a reserved word and cannot be used.
    public static var tagPolicyViolationException: Self { .init(.tagPolicyViolationException) }
    /// The Service Quotas template is not available in this AWS Region.
    public static var templatesNotAvailableInRegionException: Self { .init(.templatesNotAvailableInRegionException) }
    /// Due to throttling, the request was denied. Slow down the rate of request calls, or request an increase for this quota.
    public static var tooManyRequestsException: Self { .init(.tooManyRequestsException) }
    /// You've exceeded the number of tags allowed for a resource. For more information, see Tag restrictions in the Service Quotas User Guide.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
}

extension ServiceQuotasErrorType: Equatable {
    public static func == (lhs: ServiceQuotasErrorType, rhs: ServiceQuotasErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension ServiceQuotasErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
